<html manifest="appcache.manifest">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="../resources/sxg-util.js"></script>
<script>
const cache_ready = new Promise(resolve => {
  ['cached','noupdate'].forEach(event_name => {
    window.applicationCache.addEventListener(event_name, resolve);
  });
});

promise_test(async (t) => {
  await cache_ready;

  const sxgUrl = get_host_info().HTTPS_ORIGIN + '/signed-exchange/appcache/resources/sxg/sxg-location.sxg';
  const message = await openSXGInIframeAndWaitForMessage(t, sxgUrl);
  assert_equals(message.location, innerURLOrigin() + '/signed-exchange/appcache/resources/inner-url.html');
  assert_false(message.is_fallback);
}, 'SignedHTTPExchange cached in appcache should work.');
</script>
